package lambda_expression.jdk;

import lambda_expression.model.Person;

import java.util.UUID;
import java.util.function.Supplier;

/**
 * Supplier
 * 不接收参数，返回T对象的创建工厂
 */
public class SupplierTest {
    public static void main(String[] args) {
        // example 1
        Supplier<Person> supplier = () -> {
              return new Person("赵子龙", 56);
        };
        System.out.println(supplier.get().getAge());
        System.out.println(supplier.get().getUsername());

        // example 2
        Supplier<String> randomSupplier = () -> {
            return UUID.randomUUID().toString();
        };
        System.out.println(randomSupplier.get());
        System.out.println(randomSupplier.get());

    }
}
